package com.fenghongzhang.module_main.api


import com.fenghongzhang.lib_core.base.BaseModel
import com.fenghongzhang.module_main.ui.post.PostPageModel
import com.fenghongzhang.module_main.ui.search.SearchHotDataModel
import com.fenghongzhang.module_main.ui.search.SearchSuggestionModel

import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*
import javax.inject.Inject

/**
 * apiService
 */
interface ApiService {
    /**
     * 获取登录短信验证码
     */
    @POST(API.SMS_CODE_LOGIN)
    @FormUrlEncoded
    suspend fun getLoginSmsCode(
        @Field("phone") phone: String,
        @Field("operatorType") operatorType: Int = 2
    ): BaseModel<Boolean>

    /**
     * 绑定手机号短信验证码
     */
    @POST(API.SMS_CODE_BIND)
    @FormUrlEncoded
    suspend fun getBindSmsCode(@Field("phone") phone: String): BaseModel<Boolean>


    @GET("blank")
    suspend fun blankApi(): BaseModel<Any>
    /**
     * 获取重置密码短信验证码
     */
    @POST(API.SMS_CODE_REST)
    @FormUrlEncoded
    suspend fun getRestSmsCode(
        @Field("phone") phone: String,
        @Field("operatorType") operatorType: Int = 2
    ): BaseModel<Boolean>

    /**
     * 登录
     * {"code": "","grantType": "","operatorType": "","password": "","userName": ""}
     */
    @POST(API.AUTH_LOGIN)
    suspend fun login(@Body body: RequestBody): BaseModel<Any>

    @POST(API.AUTH_REFRESH)
    suspend fun refresh(): BaseModel<Any>


    /**
     * 关键词搜索
     */

    @GET(API.SEARCH_KEYWORD)
    suspend fun searchKeyword(
        @Query("keyword") keyword: String,
        @Query("socialType") serviceType: Int = 1
    ): BaseModel<List<SearchSuggestionModel>>


    /**
     * 搜索页面，热门数据
     */

    @GET(API.SEARCH_HOT_LIST)
    suspend fun getSearchHotData(): BaseModel<SearchHotDataModel>

    /**
     * 退出登录
     */
    @DELETE(API.AUTH_LOGOUT)
    suspend fun logout(): BaseModel<Any>

    /**
     * 重置密码
     * {"newPassword": "","operatorType": 0,"password": "","smsCode": "","userName": ""}
     */
    @POST(API.REST_PSD)
    suspend fun restPsd(@Body body: RequestBody): BaseModel<Any>

    /**
     * 分页获取帖子
     * @param category 帖子归属(0:动态 1:推荐 2:热门)
     */
    @GET(API.POST_PAGE)
    suspend fun queryPostsByPage(
        @Query("category") category: Int? = null,
        @Query("topicId") topicId: String? = null,
        @Query("vehicleModelId") vehicleModelId: String? = null,
        @Query("series") series: String? = null,
        @Query("content") content: String? = null,
        @Query("memberId") memberId: String? = null,
        @Query("ifMy") ifMy: Int? = null,
        @Query("ifFocus") ifFocus: Int? = null,
        @Query("topicCategory") topicCategory: Int? = null,
        @Query("pageNum") pageNum: Int,
        @Query("pageSize") pageSize: Int = 10,
        @Query("isAsc") isAsc: Boolean? = null,
        @Query("orderByColumn") orderByColumn: String? = null,
    ): BaseModel<PostPageModel>


}